/*
*用accumulate统计vector<int>容器对象中的元素之和
*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main()
{
	vector<int> ivec;
	ivec.push_back(2);
	ivec.push_back(5);
	ivec.push_back(4);
	ivec.push_back(1);
	ivec.push_back(8);

	int sum = accumulate(ivec.begin(),ivec.end(),0);
	cout << "vector<int>容器对象ivec中所有元素之和为:" << sum << endl;

	system("pause");
    return 0;
}